﻿using Caliburn.Micro;
using SplitMergePanel.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace SplitMergePanel
{
    public class AppBootstrapper: BootstrapperBase
    {
        SimpleContainer _container;
       public AppBootstrapper()
        {
            Initialize();
        }

        protected override void Configure()
        {
            base.Configure();
            _container = new SimpleContainer();

            _container.Singleton<IWindowManager, WindowManager>();
            _container.Singleton<IEventAggregator, EventAggregator>();
            _container.PerRequest<IShell, ShellViewModel>("ShellViewModel");
        }

        protected override object GetInstance(Type service, string key)
        {
            //return base.GetInstance(service, key);
            return _container.GetInstance(service,key);
        }

        protected override IEnumerable<object> GetAllInstances(Type service)
        {
            //return base.GetAllInstances(service);
            return _container.GetAllInstances(service);
        }

        protected override void BuildUp(object instance)
        {
            _container.BuildUp(instance);
        }

        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            DisplayRootViewFor<IShell>();
        }
    }
}
